package com.hqq.rabbitmq.event;

import org.springframework.context.ApplicationEvent;

import java.io.Serializable;

/**
 * 模拟登录事件
 * Spring事件驱动模型中“事件”类，通过“事件驱动”的方式实现业务模块之间的交互。
 * @author huangqiqin
 * @date 2021/04/10 21:09
 **/
public class LoginEvent extends ApplicationEvent implements Serializable {

    private String userName;
    private String loginName;
    private String ip;

    /**
     * 构造器一：由于继承ApplicationEvent类时需要重写的构造器
     * @param source
     */
    public LoginEvent(Object source) {
        super(source);
    }

    /**
     * 构建器二
     * @param source
     * @param userName
     * @param loginName
     * @param ip
     */
    public LoginEvent(Object source, String userName, String loginName, String ip) {
        super(source);
        this.userName = userName;
        this.loginName = loginName;
        this.ip = ip;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    @Override
    public String toString() {
        return "LoginEvent{" +
                "userName='" + userName + '\'' +
                ", loginName='" + loginName + '\'' +
                ", ip='" + ip + '\'' +
                '}';
    }
}
